package com.nancy.ioc.BeanFactoryPostProcessor;

import org.springframework.beans.BeansException;
import org.springframework.beans.MutablePropertyValues;
import org.springframework.beans.PropertyValue;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;

public class LogicBeanFactoryPostProcessor implements BeanFactoryPostProcessor {

    @Override
    public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
        BeanDefinition bd = beanFactory.getBeanDefinition("bean") ;
        MutablePropertyValues mpv = null ;
        if(bd != null && (mpv = bd.getPropertyValues())!=null){
            PropertyValue value = mpv.getPropertyValue("name");
            System.out.print("修改之前 name 的value是："+value.getValue()+"\n");
            value.setConvertedValue("postProcessBeanFactory修改属性");
        }
    }
}
